<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>角色列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="icon" href="images/logome.ico">
    <link rel="stylesheet" href="lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
</head>
<body marginwidth="0" marginheight="0">
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>角色信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <!-- <label class="layui-form-label">图书名称</label> -->
                            <div class="layui-input-inline">
                                <!-- <input type="text" name="username" autocomplete="off" class="layui-input"> -->
                            </div>
                        </div>
                        <div class="layui-inline">
                            <!-- <label class="layui-form-label">图书作者</label> -->
                            <div class="layui-input-inline">
                               <!--  <input type="text" name="sex" autocomplete="off" class="layui-input"> -->
                            </div>
                        </div>
                        <div class="layui-inline">
                            <!-- <label class="layui-form-label">图书类型</label> -->
                            <div class="layui-input-inline">
                                <!-- <input type="text" name="city" autocomplete="off" class="layui-input"> -->
                            </div>
                        </div>
                        <div class="layui-inline">
                            <!-- <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button> -->
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>


        <div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1" lay-id="currentTableId" style=" ">
        	<div class="layui-table-tool">
        		<div class="layui-table-tool-temp"> 
        			<div class="layui-btn-container"> 
        				<a  th:href="@{/addRole}"><button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button> </a>
        				<!-- <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>  -->
        			</div> 
        		</div>
        		<div class="layui-table-tool-self">
        			<div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS">
        				<i class="layui-icon layui-icon-cols"></i>
        			</div>
        			<div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT">
        				<i class="layui-icon layui-icon-export"></i></div>
        			<div class="layui-inline" title="打印" lay-event="LAYTABLE_PRINT">
        				<i class="layui-icon layui-icon-print"></i>
        			</div>
        			<div class="layui-inline" title="提示" lay-event="LAYTABLE_TIPS">
        				<i class="layui-icon layui-icon-tips"></i>
        			</div>
        		</div>
        	</div>
        	<div class="layui-table-box">
        		<div class="layui-table-header">
        			<table cellspacing="0" cellpadding="0" border="0" class="layui-table" lay-skin="line">
        				<thead>
        					<tr>
        						<th data-field="0" data-key="1-0-0" data-unresize="true" class=" layui-table-col-special">
        							<div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-checkbox">
        								<input type="checkbox" name="layTableCheckbox" lay-skin="primary" lay-filter="layTableAllChoose">
        									<div class="layui-unselect layui-form-checkbox" lay-skin="primary">
        										<i class="layui-icon layui-icon-ok"></i>
        									</div>
        							</div>
        						</th>
        						<th data-field="id" data-key="1-0-1" class=" layui-unselect">
	        						<div class="layui-table-cell laytable-cell-1-0-1">
	        							<span>ID</span>
	        							<span class="layui-table-sort layui-inline">
	        								<i class="layui-edge layui-table-sort-asc" title="升序"></i>
	        								<i class="layui-edge layui-table-sort-desc" title="降序"></i>
	        							</span>
	        						</div>


        						<th data-field="wealth" data-key="1-0-9" class=" layui-unselect">
        							<div class="layui-table-cell laytable-cell-1-0-9">
        								<span>角色名称</span>
        								<span class="layui-table-sort layui-inline">
        									<i class="layui-edge layui-table-sort-asc" title="升序"></i>
        									<i class="layui-edge layui-table-sort-desc" title="降序"></i>
        								</span>
        							</div>
        						</th>
        						<th data-field="wealth" data-key="1-0-9" class=" layui-unselect">
        							<div class="layui-table-cell laytable-cell-1-0-9">
        								<span>日期</span>
        								<span class="layui-table-sort layui-inline">
        									<i class="layui-edge layui-table-sort-asc" title="升序"></i>
        									<i class="layui-edge layui-table-sort-desc" title="降序"></i>
        								</span>
        							</div>
        						</th>
        						<th data-field="10" data-key="1-0-10" data-minwidth="150" class=" layui-table-col-special">
        							<div class="layui-table-cell laytable-cell-1-0-10" align="center">
        								<span>操作</span>
        							</div>
        						</th>
        					</tr>
        				</thead>
        			</table>
        		</div>
        		<div class="layui-table-body layui-table-main">
        			<table cellspacing="0" cellpadding="0" border="0" class="layui-table" lay-skin="line">
        				<tbody>
        					<tr data-index="0" class="" th:each="role:${role}">
        						<td data-field="0" data-key="1-0-0" class="layui-table-col-special">
        							<div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-checkbox">
        								<input type="checkbox" name="layTableCheckbox" lay-skin="primary">
        									<div class="layui-unselect layui-form-checkbox" lay-skin="primary">
        										<i class="layui-icon layui-icon-ok"></i>
        									</div>
        							</div>
        						</td>
        						<td data-field="id" data-key="1-0-1" class="">
        							<div class="layui-table-cell laytable-cell-1-0-1" th:text="${role.id}"></div>
        						
        						<td data-field="wealth" data-key="1-0-9" class="">
        							<div class="layui-table-cell laytable-cell-1-0-9"
        							 th:text="${role.roleName }"></div>
        						</td>
								<td data-field="wealth" data-key="1-0-9" class="">
        							<div class="layui-table-cell laytable-cell-1-0-9" th:text="${role.createTime}"></div>
        						</td>
        						<td data-field="10" data-key="1-0-10" align="center" data-off="true" data-minwidth="150" class="layui-table-col-special">
        							<div class="layui-table-cell laytable-cell-1-0-10"> 
        								<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit"
        								 lay-event="edit" th:href="@{/deitRole(id=${role.id})}">编辑</a> 
        								<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
        							</div>
        						</td>
        					</tr>
        		</tbody>
        	</table>
        </div>
       </div>
     <style>.laytable-cell-1-0-0{ width: 50px; }.laytable-cell-1-0-1{ width: 80px; }.laytable-cell-1-0-2{ width: 80px; }.laytable-cell-1-0-3{ width: 80px; }.laytable-cell-1-0-4{ width: 80px; }.laytable-cell-1-0-5{  }.laytable-cell-1-0-6{ width: 80px; }.laytable-cell-1-0-7{ width: 80px; }.laytable-cell-1-0-8{ width: 80px; }.laytable-cell-1-0-9{ width: 135px; }.laytable-cell-1-0-10{  }
     </style>
    </div>
        							

    </div>
</div>
<script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
        </script>
<script src="lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '../api/table.json',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            skin: 'line'
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '添加用户',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: '../page/table/add.html',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('currentTableId')
                    , data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {

                var index = layer.open({
                    title: '编辑用户',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: '',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('真的删除行么', function (index) {
                    obj.del();
                    layer.close(index);
                });
            }
        });

    });
</script>
<script type="text/javascript">
	// <![CDATA[  <-- For SVG support
	if ('WebSocket' in window) {
		(function () {
			function refreshCSS() {
				var sheets = [].slice.call(document.getElementsByTagName("link"));
				var head = document.getElementsByTagName("head")[0];
				for (var i = 0; i < sheets.length; ++i) {
					var elem = sheets[i];
					var parent = elem.parentElement || head;
					parent.removeChild(elem);
					var rel = elem.rel;
					if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") {
						var url = elem.href.replace(/(&|\?)_cacheOverride=\d+/, '');
						elem.href = url + (url.indexOf('?') >= 0 ? '&' : '?') + '_cacheOverride=' + (new Date().valueOf());
					}
					parent.appendChild(elem);
				}
			}
			var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
			var address = protocol + window.location.host + window.location.pathname + '/ws';
			var socket = new WebSocket(address);
			socket.onmessage = function (msg) {
				if (msg.data == 'reload') window.location.reload();
				else if (msg.data == 'refreshcss') refreshCSS();
			};
			if (sessionStorage && !sessionStorage.getItem('IsThisFirstTime_Log_From_LiveServer')) {
				console.log('Live reload enabled.');
				sessionStorage.setItem('IsThisFirstTime_Log_From_LiveServer', true);
			}
		})();
	}
	else {
		console.error('Upgrade your browser. This Browser is NOT supported WebSocket for Live-Reloading.');
	}
	// ]]>
</script>

</body>
</html>